#ifndef FRMKEYBOARD_H
#define FRMKEYBOARD_H
#pragma once
#pragma execution_character_set("utf-8")
#include <QDialog>
#include <QPushButton>
#include <QKeyEvent>
#include <QDebug>
#include <QStyle>
#include <QMouseEvent>

namespace Ui {
class frmKeyBoard;
}

class frmKeyBoard : public QDialog
{
    Q_OBJECT

public:
    explicit frmKeyBoard(QWidget *parent = nullptr);
    ~frmKeyBoard();
    void initFocusWidget(QWidget*);
    //设置鼠标按下可移动窗口的区域，在子窗口中必须设置该区域
    void setAreaMovable(const QRect rt);

signals:
    void hiding();

private slots:
    void slotKeyButtonClicked();
    void slotKeyLetterButtonClicked();
    void slotKeyNumberButtonClicked();

protected:
  void mousePressEvent(QMouseEvent *);
  void mouseMoveEvent(QMouseEvent *);
  void mouseReleaseEvent(QMouseEvent *);

private:
    void initFrm();
    void initStyleSheet();

    QWidget* m_focusWidget;	//键盘输入主窗口

    QVector<QPushButton*> m_letterKeys;
    QVector<QPushButton*> m_NumberKeys;
    QMap<QString, Qt::Key> m_mapSymbolKeys;

    QRect m_areaMovable;//可移动窗口的区域，鼠标只有在该区域按下才能移动窗口
    bool m_bPressed;//鼠标按下标志（不分左右键）
    QPoint m_ptPress;//鼠标按下的初始位置

private:
    Ui::frmKeyBoard *ui;
};

#endif // FRMKEYBOARD_H
